<html>
<head>
<script src="/js/c9l.js"></script>
<script language=javascript>

function show(result) {

	document.getElementById("results").innerHTML += JSON.stringify(result);
}

function submit() {

	document.getElementById("results").innerHTML = "";
	var query = document.getElementById("query").value;
	var color = document.getElementById("color").value;

	var obj = new Object();

	if (color != "") obj["color"] = color;
	if (query != "") obj["_keywords"] = {"$all":c9l.keywords(query)};

	c9l.find("ads", obj, show);
	
	document.getElementById("color").value = "";
}


//publish("/test1", "hello, world");

//subscribe("/test1", 0, alert);

</script>
</head>
<body>
Search for an ad!<br>
keyword search: <input type=text id=query></input><br>
Color: <select id=color><option></option><option>red</option><option>blue</option><option>green</option></select>
<div id=results></div><br>
<input type=submit onclick="submit()" value=Go!></input>
</body>
</html>
